import apiNeed from "@/pages/v1/erp/Need/js/apiNeed";

export default {
    data(){
        return{
            viewerModel: {id:0},
            viewerOpen:false,
        }
    },
    methods:{
        openViewer(model){
            this.viewerOpen = true
            this.viewerModel = model
        },
        fastCreate(createWhat){
            switch (createWhat){
                case "inquiry":
                    this.$confirm("正在快速创建“询价单”，是否继续？",).then(({ result }) => {
                        if (result){
                            apiNeed.fastInquiry({id:this.viewerModel.id},res=>{
                                this.$toast.success(res.message)
                                this.$confirm("询价单创建完成，是否跳转采购询价列表？",).then(({ result }) => {
                                    if (result){
                                        this.$router.push("/v1/erp/Inquiry/list")
                                    }
                                })
                            })
                        }
                    })
                    break
                case "inquiryFeedback":
                    this.$confirm("正在快速创建“供应报价单”，是否继续？",).then(({ result }) => {
                        if (result){
                            apiNeed.fastInquiryFeedback({id:this.viewerModel.id},res=>{
                                this.$toast.success(res.message)
                                this.$confirm("供应报价单创建完成，是否跳转供应报价列表？",).then(({ result }) => {
                                    if (result){
                                        this.$router.push("/v1/erp/InquiryFeedback/list")
                                    }
                                })
                            })
                        }
                    })
                    break
                case "buyOrder":
                    this.$confirm("正在快速创建“采购订单”，是否继续？",).then(({ result }) => {
                        if (result){
                            apiNeed.fastBuyOrder({id:this.viewerModel.id},res=>{
                                this.$toast.success(res.message)
                                this.$confirm("采购订单创建完成，是否跳转供采购订单列表？",).then(({ result }) => {
                                    if (result){
                                        this.$router.push("/v1/erp/BuyOrder/list")
                                    }
                                })
                            })
                        }
                    })
                    break
            }
        },
    },
    props:{
        params:{},//列表初始且无法覆盖的筛选条件
        base:{},//数据新建的时候默认的值
    }
}